(define (product a term next b)
    (if (> a b)
        1
        (* (term a)
           (product (next a) term next b))))

"(define (product a term next b)
    (define (iter a b result)
        (if (> a b)
            result
            (iter (next a) b (* (term a) result))))
    (iter a b 1))
"
(define (pi n)
    (define (pi-term n) (- 1 (/ 1 (square n))))
    (define (pi-next n) (+ n 2))
    (* (product 3 pi-term pi-next n)
       4.0))

(define (square x) (* x x))

(define (multi a b)
    (product a identity inc b))
(define (identity x) x)
(define (inc x) (+ x 1))
